package com.my.hotel.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.my.hotel.entity.User;
import com.my.hotel.service.KhService;
import org.apache.http.HttpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping(value = "/kh",produces = "text/html;charset=utf-8")
public class KhController {

    @Autowired
    private KhService khService;

    @RequestMapping("/khPage")
    public String getUserList(Integer pageNo, Model model,String type){
        if (pageNo==null){
            pageNo=1;
        }
        PageHelper.startPage(pageNo,10);
        if (type==null){
            type="";
        }
        List<User> userList = khService.getUserList(type);
        PageInfo<User> page = new PageInfo<User>(userList);
        model.addAttribute("page",page);
        return "khPage";
    }
}
